package com.king01.controller;

import com.king01.annotation.LogAnnotation;
import com.king01.entity.Staff;
import com.king01.service.StaffService;
import com.king01.vo.Result;
import com.king01.vo.StaffExVo;
import com.king01.vo.StaffVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @author ：lqs
 * @date ：Created in 2023/9/25 17:40
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("/staff")
public class StaffController {

    @Autowired
    private StaffService staffService;
    private String business_type;

    @RequestMapping("/info")
    public Result info(HttpSession session){
        Object staff = session.getAttribute("staff");
        return new Result(200,"获取用户信息",staff);
    }



    @RequestMapping("/list")
    @LogAnnotation(business_type = "查询角色操作")
    public Result list(Integer current, Integer pageSize, @RequestBody StaffVo staffVo) {
        Result result = staffService.findAll(current, pageSize, staffVo);
        return result;
    }

    @RequestMapping("/findAllStaffByStaffid")
    public Result findAllStaffByStaffid() {
        Result result = staffService.findAllStaffByStaffid();
        return result;
    }



    @RequestMapping("/update1")
    @LogAnnotation(business_type = "离职员工操作")
    public Result update1(Integer staffid){
        Result result = staffService.update1(staffid);
        return  result;
    }
//    @RequestMapping("/insert")
//    public Result insert(@RequestBody Staff staff){
//        Result result = staffService.insert(staff);
//        return result;
//    }
    @RequestMapping("/update2")
    @LogAnnotation(business_type = "编辑员工操作")
    public Result update2(@RequestBody Staff staff){
        System.out.println(staff);
            Result result = staffService.update2(staff);
            return  result;
        }
    @RequestMapping("/select1")
    public Result select1(){
        Result result1 = staffService.select1();
        return  result1;
    }
    @RequestMapping("/select2")
    public Result select2(){
        Result result1 = staffService.select2();
        return  result1;
    }
    @RequestMapping("/select3")
    public Result select3(){
        Result result1 = staffService.select3();
        return  result1;
    }

    @RequestMapping("/selectStaff")
    public Result selectStaff(){
        Result result = staffService.findAllStaff();
        return result;
    }


    @RequestMapping("/add1")
    @LogAnnotation(business_type = "添加员工操作")
    public Result add1(@RequestBody Staff staff){
        Result result1 = staffService.add1(staff);
        return  result1;
    }

    @RequestMapping("/selectIf")
    public Result selectIf(Integer staffid){
        Result result = staffService.selectIF(staffid);
        System.out.println("111111111"+result);
        return  result;
    }
    @RequestMapping("/add2")
    public Result add2(@RequestBody StaffExVo staffExVo){
        Result result = staffService.add2(staffExVo);
        System.out.println("-----"+result);
        return  result;
    }

    @RequestMapping("/dj1")
    @LogAnnotation(business_type = "冻结员工操作")
    public Result dj1(Integer staffid){
        Result result = staffService.dj1(staffid);
        return  result;
    }

    @RequestMapping("/dj2")
    @LogAnnotation(business_type = "解冻员工操作")
    public Result dj2(Integer staffid){
        Result result = staffService.dj2(staffid);
        return  result;
    }
}

